import { FC, useEffect } from 'react';
import { Amplify } from 'aws-amplify';
import { fetchAuthSession } from 'aws-amplify/auth';
import { PubSub } from '@aws-amplify/pubsub/mqtt';

const pubsub = new PubSub({
  endpoint: 'wss://a3etb6udiwzsxp-ats.iot.us-east-1.amazonaws.com/mqtt'
});

const AwsTest: FC = () => {

  useEffect(() => {
    pubsub.subscribe({
      topics: ['ioc-common-channel']
    }).subscribe({
      next: data => {
        console.log(data);
      },
      error: err => {
        console.error(err);
      },
      complete: () => {
        console.log('complete...')
      }
    });
  },[])
  return (
    <div>
      qqq
    </div>
  )
}

export default AwsTest;